<%@ page session="false" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

<h:panelGroup>
	<fieldset><legend>Dane pozycji zamówienia</legend>

		<tr:commandLink action="#{orderController.editInvitationItem}"
									rendered="#{orderController.editedInvitation}"
									shortDesc="Zapisz zmiany" inlineStyle="margin-left:5px">
				<tr:image source="gfx/save_button.png" />
		</tr:commandLink>
		<tr:commandLink action="#{orderController.addInvitationToOrder}"
									rendered="#{! orderController.editedInvitation}"
									shortDesc="Dołącz do zamówienia" inlineStyle="margin-left:5px">
				<tr:image source="gfx/save_button.png" />
		</tr:commandLink>
	
	<table width="100%" border="0">
		<tr>
			<td align="right">Data ślubu/wesela:</td>
			<td><tr:panelGroupLayout>
				<t:inputDate id="weddingDateTime" type="both" required="false"
					styleClass="input_text" value="#{invitationBean.weddingDateTime}"
					popupCalendar="true" ampm="false" />
				<h:message for="weddingDateTime" styleClass="validation_info" />
			</tr:panelGroupLayout></td>
			<td align="right">Nazwisko i imię Pana Młodego:</td>
			<td width="25%"><tr:inputText contentStyle="width:100%"
				id="bridegroom" simple="true"
				value="#{invitationBean.bridegroom}" required="false"/>
				 <tr:message for="bridegroom" styleClass="validation_info" />
			</td>
		</tr>
		<tr>
			<td align="right">Zaślubiny w:</td>
			<td><tr:inputText id="weddingplace" simple="true"
				value="#{invitationBean.weddingplace}"  contentStyle="width:100%" /></td>
			<td align="right">Nazwisko i imię Panny Młodej:</td>
			<td width="30%">
			<tr:inputText id="bridename" simple="true" contentStyle="width:100%"
				value="#{invitationBean.bridename}" required="false" /> <h:message
				for="bridename" styleClass="validation_info" /></td>
		</tr>

		<tr>
			<td align="right">Przyjęcie weselne w:</td>
			<td><tr:inputText id="weddingpartyplace" simple="true"
				value="#{invitationBean.weddingpartyplace}" contentStyle="width:100%"/>
			</td>
			<td align="right"><b>Całkowita ilość zaproszeń:</b></td>
			<td><tr:inputText id="totalCount"
				value="#{invitationBean.totalCount}" simple="true"
				shortDesc="Całkowita ilość zaproszeń"
				onkeypress="return checkField(window.event, DIGIT_FIELD)"  
				contentStyle="width:100%"/> 
				<h:message for="totalCount" styleClass="validation_info" />
			</td>
		</tr>

		<tr>
			<td align="right">Kod pozycji:</td>
			<td>
			<tr:inputText id="code" value="#{invitationBean.code}"
							maximumLength="30" shortDesc="Kod pozycji/zaproszenia"
							required="true"
							contentStyle="width:100%;text-transform:uppercase" />
			</td>
			<td align="right">Ilość z nadrukiem:</td>
			<td><tr:inputText id="overPrintCount"
				value="#{invitationBean.overPrintCount}"
				shortDesc="Ilość z nadrukiem" simple="true"
				onkeypress="return checkField(window.event, DIGIT_FIELD)"
				contentStyle="width:100%">
				<tr:convertNumber integerOnly="true" />
			</tr:inputText> <h:message for="overPrintCount" styleClass="validation_info" /></td>
		</tr>
		<tr>
			<td align="right">Numer czcionki:</td>
			<td>
				<tr:inputText id="fontType"
							value="#{invitationBean.fontType}" shortDesc="Numer czcionki"
							required="true"
							contentStyle="width:100%" /> 
			</td>
			<td align="right">Ilość z personalizacją:</td>
			<td><tr:inputText id="personalizecount"
				value="#{invitationBean.personalizecount}" simple="true"
				onkeypress="return checkField(window.event, DIGIT_FIELD)"
				contentStyle="width:100%"/>
				<h:message for="personalizecount" styleClass="validation_info" />
			</td>
		</tr>
		<tr>
			<td align="right">Kolor nadruku:</td>
			<td>
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td><tr:selectOneChoice id="fontColor" value="#{invitationBean.fontColor}" 
											required="false" simple="true">
						<f:selectItem itemLabel="--BRAK--" itemValue="0"/>
						<f:selectItems value="#{ConstantDictionaries.overPrintColor}" />
					</tr:selectOneChoice> <h:message for="fontColor" styleClass="validation_info" /></td>
					<td align="right">Kolor okładki:</td>
					<td><tr:selectOneChoice id="coverColor" value="#{invitationBean.coverColor}"
											required="false" simple="true">
							<f:selectItem itemLabel="--BRAK--" itemValue="0"/>
							<f:selectItems value="#{ConstantDictionaries.overPrintColor}" />
						</tr:selectOneChoice> 
						<h:message for="coverColor" styleClass="validation_info" />
					</td>
				</tr>
			</table>

			</td>
			<td align="right">Ilość kopert z personalizacją:</td>
			<td>
				<tr:inputText id="personalizeEnvelopCount" simple="true"
								value="#{invitationBean.envelopepersonalizecount}"
								shortDesc="Ilość kopert z personalizacją" required="false"
								onkeypress="return checkField(window.event, NUMBER_FIELD)"
								requiredMessageDetail="Ilość kopert z personalizacją jest wymagana"
								contentStyle="width:100%" /> 
					<h:message for="personalizeEnvelopCount" styleClass="validation_info" />
			</td>
		</tr>
		<tr>
			<td align="right">Cena jednostkowa [PLN]:</td>
			<td>
			    <tr:inputText maximumLength="10" id="unitprice" value="#{invitationBean.unitprice}"
                              onkeypress="return checkField(window.self.event, NUMBER_FIELD)"
                              shortDesc="Cena jednostkowa" required="true" simple="true">
                    <f:convertNumber groupingUsed="false" maxFractionDigits="2" minFractionDigits="2" locale="pl"/>
                </tr:inputText>
                <h:message for="unitprice" styleClass="validation_info" />
			</td>
			<td align="right"><b>Suma [PLN]:</b></td>
			<td><b> 
				<h:outputText value="#{invitationBean.amount}" title="Suma">
					<f:convertNumber groupingUsed="false" maxFractionDigits="2" minFractionDigits="2" locale="pl" />
				</h:outputText>
				</b>
			</td>
		</tr>
		<tr>
			<td align="right"></td>
			<td colspan="2"><h:panelGrid columns="3" style="width:100%">
				<tr:selectBooleanCheckbox id="isPaperChanged"
					value="#{invitationBean.paperChanged}" label="Zmiana papieru:" />
				<tr:selectBooleanCheckbox id="assembling"
					value="#{invitationBean.assembling}" label="Składanie:" />
				<tr:selectBooleanCheckbox id="cuttingNames"
					value="#{invitationBean.cuttingNames}" label="Wypalanie:" />
			</h:panelGrid></td>
			<td align="right"></td>
		</tr>
		<tr>
			<td align="right">Uwagi:</td>
			<td colspan="3">
				<tr:inputText simple="true" columns="50" rows="4" id="note"
							value="#{invitationBean.note}" shortDesc="Uwagi"
							contentStyle="width:100%;" />
			</td>
		</tr>
	</table>
	</fieldset>
	
	<jsp:include page="/invitation_fees.jsp" flush="true" />
	
	<fieldset>
	
	<legend>Wybrane teksty</legend>

		<tr:commandLink inlineStyle="margin-right:5px" useWindow="true" blocking="true"
						windowHeight="600" windowWidth="800"
						action="#{NavigationUtil.goToTextListPopup}" id="selectTexts"
						returnListener="#{orderController.returnTextList}"
						shortDesc="Wybierz teksty do zaproszenia">
				<tr:image source="gfx/add32.png" />
		</tr:commandLink>

	<tr:commandLink inlineStyle="margin:5px"
					rendered="#{not empty invitationBean.textList}"
					shortDesc="Usuń wybrane teksty z zaproszenia"
					actionListener="#{orderController.removeSelectedTexts}">
			<tr:image source="gfx/delete32.png" />
	</tr:commandLink>

		<tr:table binding="#{orderController.selectedTextListDataTable}"
					width="100%" rowSelection="multiple" verticalGridVisible="false"
					rowBandingInterval="1" emptyText="Brak tekstĂłw"
					rendered="#{not empty invitationBean.textList}"
					horizontalGridVisible="false" value="#{invitationBean.textList}"
					var="text" rows="10">
		<tr:column sortable="true" sortProperty="type" width="200">
			<f:facet name="header">
				<h:outputText value="rodzaj tekstu" />
			</f:facet>
			<tr:selectOneListbox id="type" value="#{text.type}" readOnly="true">
				<f:selectItems value="#{ConstantDictionaries.textType}" />
			</tr:selectOneListbox>
		</tr:column>
		<tr:column sortable="true" sortProperty="code" width="100">
			<f:facet name="header">
				<h:outputText value="kod tekstu" />
			</f:facet>
			<h:outputText value="#{text.code}" />
		</tr:column>
		<tr:column inlineStyle="text-align:center"
			shortDesc="#{text.description}">
			<f:facet name="header">
				<h:outputText value="treść" />
			</f:facet>
			<h:outputText value="#{text.content}" />
		</tr:column>
	</tr:table>
</fieldset>

</h:panelGroup>
